package br.com.atibrasil.fx.aplication;


import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import javafx.application.Application;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.ProgressIndicator;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
 
public class GUISplash extends Application {	
    @FXML
    private ProgressIndicator pi;
    public static Stage stage = null;
    private static Properties p = new Properties();  	
	private static String CONFIG_NOME_APLICACAO ="NOME_APLICACAO";	
	private static String CONFIG_NOME_EMPRESA ="NOME_EMPRESA";
	private static String CONFIG_LOGO= "LOGO";			
	public static String NOME_APLICACAO;		
	public static String NOME_EMPRESA;	
	public static InputStream LOGO;	
	@Override
	public void start(Stage stage) throws Exception {
		this.stage = stage;
		execute();
	}
	
	public static void main(String[] args) {
		launch(null);
	}
	
	public static void execute(){
		Parent root;	
		try {	
			loadParametros();
			root = FXMLLoader.load(GUIController.class.getResource("/br/com/atibrasil/fx/fxml/splashForm.fxml"));	
		} catch (IOException e) {
			e.printStackTrace();
			return;
		}	
		Scene scene = new Scene(root);
		stage.setScene(scene);		
		stage.sizeToScene();
		stage.initStyle(StageStyle.TRANSPARENT);
		stage.setResizable(false);
		stage.show();		
	}
	
	public static void close(){
		stage.close();
		//GUILogin.execute();	
		GUIController.execute(GUISplash.NOME_APLICACAO);
	}
	
	public static void loadParametros(){
		try {
			p.load(Inicial.class.getResourceAsStream("/config.properties"));
			NOME_APLICACAO = p.getProperty(CONFIG_NOME_APLICACAO);						
			NOME_EMPRESA = p.getProperty(CONFIG_NOME_EMPRESA);		
			//LOGO = Inicial.class.getClass().getResourceAsStream(p.getProperty(CONFIG_LOGO));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
